package com.dhc.redpacket.advice;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class MyExceptionResponse {
  /**
   * 错误处理
   *
   * @param e
   * @return
   */
  @ExceptionHandler(Exception.class)
  @ResponseBody
  public com.dhc.redpacket.common.ResponseBody handlerMyException(Exception e) {
    e.printStackTrace();
    com.dhc.redpacket.common.ResponseBody body = new com.dhc.redpacket.common.ResponseBody();
    body.setMsg(e.getMessage());
    body.setCode(-1);
    body.setData(false);
    return body;
  }
}
